
<!-- 公共svgicon组件 -->
<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName"/>
  </svg>
</template>

<script>
export default {
  name: 'SvgIcon',
  props: {
    // 传入需要使用的 svg 名字 必穿
    iconClass: {
      type: String,
      required: true
    },
    className: {
      type: String,
      default: ''
    }
  },
  computed: {
    iconName () {
      return `#icon-${this.iconClass}`
    },
    svgClass () {
      if (this.className) {
        return `svg-icon icon-${this.iconClass} ` + this.className
      } else {
        return `svg-icon icon-${this.iconClass}`
      }
    }
  }
}
</script>

<style lang="scss">
.svg-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  fill: currentColor;
  overflow: hidden;
}
</style>
